{extend name="extra@admin/content"}

{block name="content"}
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" class='layui-form' style='padding-top:20px'>
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 400px;">
                <span class="">属性</span>
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <span class="">价格</span>
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <span class="">积分</span>
            </div>
        </div>
    </div>
    {foreach name="spec_res" item="vo" key="k"}
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 400px;">
                <input type="text" name="title[]" autocomplete="off" required="required"  class="layui-input disabled" readonly="readonly" value="{$vo.0}">
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="price[]" autocomplete="off" required="required" placeholder="请输入属性价格" class="layui-input" value="{if condition='!empty($vo.price)'} {$vo.price} {/if}" {if condition='!empty($vo.price)'} readonly="readonly" {/if}>
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="score[]" autocomplete="off" required="required" placeholder="请输入积分" class="layui-input" value="{if condition='!empty($vo.score)'} {$vo.score} {/if}" {if condition='!empty($vo.score)'} readonly="readonly" {/if}>
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="hidden" name="specs[]" autocomplete="off" required="required" placeholder="" class="layui-input" value="{$vo.specs}">
            </div>
            {if isset($vo.id)}<input type="hidden" name="id[]" value="{$vo.id}">{/if}
            <!-- <span class="layui-btn tianjiayihan" type="btn" onclick="reduce(this);">移除</span> -->
        </div>
    </div>
    {/foreach}
    <div class="hr-line-dashed"></div>
    <div class="col-sm-4 col-sm-offset-2">
        {if isset($goods_id)}<input type='hidden' value='{$goods_id}' name='goods_id'/>{/if}
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存配置</button>
        </div>
    </div>
    <script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form;      //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
    function reduce(obj){
        var id = $(obj).attr('data-id');
        $.post('{:url("Goods/del_spec")}',
        {id:id},
        function(data){
            if(data.code == 1){
                $(obj).parent().remove();
            }
        });
        $(obj).parent().parent().remove();
    }
</script>
</form>

{/block}